﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;

namespace BookClubPortal.Models
{
    public class Book
    {
        public int BookId { get; set; }
        [Required(ErrorMessage = "A Book Title is required.")]
        [StringLength(160)]
        public string Title { get; set; }
        [Required(ErrorMessage = "An Author is required.")]
        [StringLength(80)]
        public string Author { get; set; }
        [Required(ErrorMessage = "A Release Year is required.")]
        [Display(Name = "Release Year")]
        [Range(0, 3000)]
        public int ReleaseYear { get; set; }
        [Display(Name = "Description")]
        [StringLength(1000)]
        public string Description { get; set; }
        [Display(Name = "Image")]
        [RegularExpression(@"(^http(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$)|(\/Content\/Images\/logo\.png)", ErrorMessage = "URL format is wrong.")]
        public string ImageURL { get; set; }
        [Display(Name = "Genre")]
        [Required(ErrorMessage = "A Genre is required.")]
        public int GenreId { get; set; }
        public Genre Genre { get; set; }
        public int UserId { get; set; }
        public User Owner { get; set; }
    }
}